<template>
    <div>
        <van-nav-bar id="reset" title="审核列表" left-arrow @click-left="backHandle" fixed z-index="100" />


        <div class="pageCon fuPage">
            <template v-if="applyList.length != 0">
                <div class="itemBox" v-for="(item, index) in applyList" :key="index">
                    <div class="line1">
                        <span>{{ item.userName }}</span>
                        <span>
                            <span @click="apply(item, 1)" class="applyBtn">通过</span>
                            <span @click="apply(item, 0)" class="applyBtn applyBtn1">驳回</span>
                        </span>
                    </div>
                    <div>
                        <span>{{ item.doctorName }}的{{ item.orderType == 0 ? '加号' : '亲情就诊' }}申请</span>
                        <span>{{ item.createTime }}</span>
                    </div>
                    <div class="imgBox" v-if="item.imgList.length != 0">
                        <span>相关图片</span>
                        <div>
                            <img :src="ele.imgUrl" alt="" v-for="(ele, eIndex) in item.imgList" :key="eIndex"
                                @click="checkImg(item.imgList, eIndex)">
                        </div>
                    </div>
                </div>

            </template>
            <div class="emptyBox" v-else>
                <img src="../../assets/tip_content.png">
            </div>


        </div>




        <van-popup v-model="tipShow" round>
            <div class="duiBox">
                <div>
                    驳回原因
                </div>
                <div class="inputBox">
                    <span>原因：</span>
                    <input type="text" v-model="text" placeholder="请输入驳回原因">
                </div>
                <div class="duiBtn">
                    <div @click="tipShow = false">取消</div>
                    <div @click="tipConfirm">提交</div>
                </div>
            </div>
        </van-popup>

    </div>

</template>

<script>
import { ImagePreview } from 'vant';
import { listApplyList, applyOrder } from '../../network/notice'
export default {
    name: 'HomeR',
    data() {
        return {
            active: '',
            noticeList: [],
            applyList: [],
            text: '',//驳回原因
            tipShow: false,
            userType: localStorage.userType,
            applyFlag: 0,//  1 通过  0 驳回
            selectObj: '',//当前操作的 订单
            isLoading: false
        }
    },
    mounted() {

    },
    methods: {
        apply(obj, flag) {
            this.text = ''
            this.applyFlag = flag
            this.selectObj = obj
            if (this.applyFlag == 1) {
                this.tipConfirm()
                return
            }
            this.tipShow = true



        },

        tipConfirm() {
            if (this.applyFlag == 0 && this.text == '') {
                this.$toast('请输入驳回原因')
                return
            }
            console.log(this.selectObj);
            console.log(this.text);
            console.log(this.applyFlag);
            // return

            var obj = {
                orderId: this.selectObj.orderId,
                status: this.applyFlag,
                note: this.text
            }

            applyOrder(obj).then(res => {
                if (res.flag) {
                    this.tipShow = false
                    this.$toast('审核成功')
                    this.getApplyList()
                }
            })
        },


        backHandle() {
            this.$router.back()
        },

        pullHandle() {

            this.isLoading = true
            this.getApplyList()
        },

        getApplyList() {
            listApplyList({
                userId: localStorage.userId
            }).then(res => {
                if (res.flag) {
                    this.isLoading = false
                    this.applyList = res.data.reverse()
                }
            })

        },


        checkImg(list, index) {

            console.log(list);
            var arr = []
            list.forEach(item => {
                arr.push(item.imgUrl)
            })
            console.log(arr);
            ImagePreview({
                images: arr, // 需要预览的图片 URL 数组
                showIndex: true, // 是否显示页码
                closeable: true, // 是否显示关闭图标	
                startPosition: index,
                showIndicators: true
            })
        },

    },
    created() {
        this.getApplyList()

    },
    //计算属性
    computed: {

    },
    filters: {

    }

}

</script>

<style lang='less' scoped>
.pageCon {
    // padding-top: 180px !important;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: #EEF1F7;
    // overflow: hidden;
}


#reset /deep/ .van-nav-bar__left .van-nav-bar__text,
#reset /deep/ .van-nav-bar__left .van-icon {
    color: #333 !important;
}



.topBox {
    position: fixed;
    top: 80px;
    box-sizing: border-box;
    padding: 32px 38px;
    width: 750px;
    background: linear-gradient(180deg, #ECFBF6, #FAFAFA);
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 28px;
    color: #01CBD7;
    z-index: 20;
}

.topBox>img {
    width: 107px;
    height: 33px;
}


.noticeBox {
    width: 100%;
    background-color: #fff;
}

.noticeBox>div {
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    padding: 24px 0px 0px 24px;
    width: 100%;
    /* background-color: aqua; */
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 30px;
    color: #333333;
}

.noticeBox>div>img {
    margin-right: 22px;
    width: 88px;
    height: 88px;
    border-radius: 20px;
}

.noticeBox>div>div>div:first-child {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.noticeBox>div>div>div:first-child>span:nth-child(2) {
    font-size: 24px;
    color: #CCCCCC;
}

.noticeBox>div>div {
    flex: 1;
    /* background-color: aquamarine; */
    padding: 0 30px 34px 0;
    border-bottom: 2px solid #f2f2f2;
}

.noticeBox>div>div>div:last-child {
    margin-top: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 24px;
    color: #999999;
}


.emptyBox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.emptyBox>img {
    margin-top: 400px;
    width: 374px;
    height: 314px;
}


.itemBox {
    margin-top: 20px;
    box-sizing: border-box;
    padding: 44px 30px 44px 44px;
    width: 100%;
    border-bottom: 2px solid #f2f2f2;
    background: #fff;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0px 2px 6px 0px rgba(51, 51, 51, 0.08);
}

.itemBox>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 28px;
    color: #333333;
    line-height: 38px;

}

.itemBox>div:nth-child(2) {
    margin-top: 12px;
}

.itemBox>div:nth-child(2)>span {
    font-size: 24px;
    color: #999999;
}



/deep/ .van-tabs__line {
    background: #1BB26A !important;
}



.duiBox {
    position: relative;
    width: 642px;
    // height: 590px;
    background: #FAFAFA;
    border-radius: 20px;
    color: #333333;
    line-height: 64px;
    font-family: Source Han Sans CN;

}

.duiBox>div:first-child {
    padding-top: 24px;
    text-align: center;
    width: 100%;
    font-weight: bold;
    font-size: 34px;

}

.duiBtn {
    // position: absolute;
    // bottom: 0px;
    display: flex;
    align-items: center;
    width: 100%;
    height: 90px;
    border-top: 2px solid #f2f2f2;
}

.duiBtn>div {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 28px;
}

.duiBtn>div:last-child {
    border-left: 2px solid #f2f2f2;
}

.inputBox {
    box-sizing: border-box;
    padding: 24px 48px;
    display: flex;
    align-items: center;
    width: 100%;
    font-size: 28px;
}

.inputBox>input {
    width: 60%;
    border: none;
    outline: none;
    background: transparent;
}


.imgBox {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    padding-top: 24px;
    border-top: 1px solid #f2f2f2;
    width: 100%;
}

.imgBox>span {
    font-size: 28px;
    color: #999;
}

.imgBox>div>img {
    margin: 16px 16px 16px 0;
    width: 100px;
    height: 100px;
    // background: aqua;
    border-radius: 16px;
}


.line1>span:nth-child(2) {
    display: flex;
    align-items: center;
    justify-content: center;

}

.applyBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 136px;
    height: 48px;
    border-radius: 24px;
    border: 1px solid rgba(27, 178, 106, .5);
    font-family: Source Han Sans CN;
    font-weight: bold;
    font-size: 20px;
    color: #1BB26A !important;
}

.applyBtn1 {
    margin-left: 16px;
    border: 1px solid rgba(255, 22, 22, 0.5);
    color: rgba(255, 22, 22) !important;
}
</style>